﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using HNQXYJ.Model;
using System.Web.Script.Serialization;

namespace HNQXYJ.BLL
{
    /// <summary>
    /// AreaGroupASH 的摘要说明
    /// </summary>
    public class AreaGroupASH : IHttpHandler, IRequiresSessionState 
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string action = context.Request["action"];
            int id = Convert.ToInt32(context.Request["id"]);
            if (action == "GetGroupList")
            {
                string ranklevel = context.Session["ranklevel"].ToString();
                List<AreaGroup> list = new List<AreaGroup>();
                list = new AreaGroupBLL().GetListByRankLevel(ranklevel);
                JavaScriptSerializer jss = new JavaScriptSerializer();
                context.Response.Write(jss.Serialize(list));  
            }

            if (id > 0)
            {
                int res = new AreaGroupBLL().DeleteDataById(id);
                if (res > 0)
                {
                    context.Response.Redirect("../HN_AreaGroup/AreaGroupMgr.aspx");
                }
            }
            //context.Response.Write("Hello World");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}